home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 320 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  30 lines

  1. Path: seas.smu.edu!not-for-mail
  2. From: dbowman@post.smu.edu (Damon Bowman)
  3. Newsgroups: comp.lang.c++
  4. Subject: beginner question - constants
  5. Date: 3 Jan 1996 12:28:48 -0600
  6. Organization: Southern Methodist University
  7. Sender: usenet@seas.smu.edu
  8. Message-ID: <4ceht0$ruj@sun.cis.smu.edu>
  9. Reply-To: dbowman@post.smu.edu
  10. NNTP-Posting-Host: sun.cis.smu.edu
  11. X-Nntp-Posting-Host: ax4-10.ppp.smu.edu
  12. X-Newsreader: Forte Free Agent 1.0.82
  13.  
  14.  
  15. Can anyone explain to me the functional difference between a
  16. macro-based constant and a formal constant?  I understand that by
  17. using the #define directive, the preprocessor replaces all instances
  18. of the constant in the code with itÆs value.  I also understand that
  19. formal constants (using the const keyword) do not undergo this
  20. replacement.
  21.  
  22. What I donÆt understand is why one might be better than another and
  23. what conditions might influence me to choose one over the other.  They
  24. appear to be two versions of the same thing.
  25.  
  26. Is it a speed issue?  Intuitively, the macro-based constant seems like
  27. it would process faster.  WhatÆs the tradeoff?
  28.  
  29.  
  30.